package com.wuba.rxjavademo.lyz.day0614;

import com.wuba.rxjavademo.lyz.BaseDemo;

import rx.Observable;
import rx.Subscriber;
import rx.functions.Action0;
import rx.functions.Func1;
import rx.schedulers.Schedulers;

/**
 * Created by liyaxing on 2016/6/17.
 */
public class Demo01 extends BaseDemo{

    public static void main(String[] ss){
        Observable.create(new Observable.OnSubscribe<String>() {
            @Override
            public void call(Subscriber<? super String> subscriber) {
                subscriber.onNext("");
            }
        }).map(new Func1<String, Void>() {
            @Override
            public Void call(String s) {
                return null ;
            }
        })
        .observeOn(Schedulers.io())
        .doOnTerminate(new Action0() {
            @Override
            public void call() {
                print("[doOnTerminate]");
            }
        }).subscribe(new Subscriber<Void>() {
            @Override
            public void onCompleted() {
                print("[onCompleted]");
            }

            @Override
            public void onError(Throwable e) {
                print("[onError]");
            }

            @Override
            public void onNext(Void s) {
                print("[onNext]");
            }
        }) ;
    }

}
